package com.niezhiliang.springboot.rabbitmq.common.aspect;

import com.niezhiliang.springboot.rabbitmq.common.annotation.MQCutHandler;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;


@Aspect
@Component
public class MQCutHandlerAspect
{
    private static final Logger logger = LoggerFactory.getLogger(MQCutHandler.class);




    @Pointcut("@annotation(com.niezhiliang.springboot.rabbitmq.common.annotation.MQCutHandler)")
    public void pointCut() {

    }

    @Around("pointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        long beginTime = System.currentTimeMillis();
        // 执行方法
        Object result = point.proceed();
        // 执行时长(毫秒)
        long time = System.currentTimeMillis() - beginTime;
        //异步保存日志
        System.out.println("执行时长:"+time);
        return result;
    }

    @Before("pointCut()")
    public void doBefore(JoinPoint joinPoint){

        System.out.println("aaaaaaaaaaaaa"+joinPoint.toString());
    }


}

